package monopoly.View;


import javax.swing.JPanel;

import monopoly.Model.Figur;


public class MoveThread extends Thread {

    private SpielbrettPanel pane;
    private int             vonPos = 0;
    private int             bisPos = 0;
    private Figur           f;

    public MoveThread( SpielbrettPanel pane, Figur f ) {
        this.pane = pane;
        this.bisPos = f.getPosition();
        this.vonPos = pane.playerPos[f.getId()];
        this.f = f;

    }

    public void run() {
        int aktPos = this.vonPos;
        try {
        	while (aktPos>this.bisPos+1) {
        		
        		if ( aktPos >= 40 ) {
                    aktPos = 0; 
                    break;
                }
        		pane.playerPos[f.getId()] = aktPos;
                pane.ownRepaint( pane.getGraphics() );
                Thread.sleep( 150 );
                aktPos++;
			}
            while ( aktPos < this.bisPos + 1 ) {
                pane.playerPos[f.getId()] = aktPos;
                pane.ownRepaint( pane.getGraphics() );
                Thread.sleep( 150 );
                aktPos++;
            }
        } catch ( Exception e ) {
            e.printStackTrace();
        }

    }
}
